package com.eclipse.e0114_java8.java8_日期时间api;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;

public class Test {
	public static void main(String[] args) {
		// 获取当前的日期时间 年月日时分秒
	      LocalDateTime currentTime = LocalDateTime.now();
	      System.out.println("当前时间: " + currentTime);
	      
	      //年月日
	      LocalDate date1 = currentTime.toLocalDate();
	      System.out.println("date1: " + date1);
	      
	      //获取月日秒
	      Month month = currentTime.getMonth();
	      int day = currentTime.getDayOfMonth();
	      int seconds = currentTime.getSecond();
	      System.out.println("月: " + month +", 日: " + day +", 秒: " + seconds);
	      
	      //修改时间
	      LocalDateTime date2 = currentTime.withDayOfMonth(10).withYear(2012).withMonth(3);
	      System.out.println("修改后的时间: " + date2);
	}
}
